<%@ page import="database.UserDb" %>
<%@ page import="database.User" %><%--
  Created by IntelliJ IDEA.
  User: jimmyhsu
  Date: 2016/12/17
  Time: 12:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%
        if (request.getSession().getAttribute("login") == null || !(Boolean)request.getSession().getAttribute("login")) {
            response.getWriter().print("<script>location.href='../Student/login.html';</script>");
        }
        String username = (String) request.getSession().getAttribute("username");
        String password = (String) request.getSession().getAttribute("password");
        User currentUser = UserDb.selectUserById(username);
        if (currentUser == null || !currentUser.getPassword().equals(password)) {
            request.getSession().setAttribute("login", false);
            response.getWriter().print("<script>location.href='../Student/login.html';</script>");
        }
    %>
</head>
<body>

</body>
</html>
